package com.xbongbong.pro.enums.menu.enums;


import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * 视图枚举类
 * @author jiping.yang
 * @version v1.0
 * @date 2021/9/6 16:06
 * @since v1.0
 */
@Getter
public enum MultiDimensionViewEnum {
    WAIT_INSTOCK_PRODUCT_VIEW(XbbRefTypeEnum.PRODUCT.getCode(),"enum.MultiDimensionViewEnum.view.wait_instock_product_view","enum.MultiDimensionViewEnum.viewName.wait_instock_product_view_name",XbbRefTypeEnum.WAIT_INSTOCK_PURCHASE.getCode()),
    WAIT_INSTOCK_PURCHASE_VIEW(XbbRefTypeEnum.PURCHASE.getCode(),"enum.MultiDimensionViewEnum.view.wait_instock_purchase_view","enum.MultiDimensionViewEnum.viewName.wait_instock_purchase_view_name", XbbRefTypeEnum.WAIT_INSTOCK_PURCHASE.getCode()),
    WAIT_OUTSTOCK_PRODUCT_VIEW(XbbRefTypeEnum.PRODUCT.getCode(),"enum.MultiDimensionViewEnum.view.wait_instock_product_view","enum.MultiDimensionViewEnum.viewName.wait_instock_product_view_name",XbbRefTypeEnum.WAIT_OUTSTOCK.getCode()),
    WAIT_OUTSTOCK_CONTRACT_VIEW(XbbRefTypeEnum.CONTRACT.getCode(), "enum.MultiDimensionViewEnum.view.wait_outstock_contract_view","enum.MultiDimensionViewEnum.viewName.wait_outstock_contract_view_name",XbbRefTypeEnum.WAIT_OUTSTOCK.getCode()),
    WAIT_PURCHAS_PRODUCT_VIEW(XbbRefTypeEnum.PRODUCT.getCode(),"enum.MultiDimensionViewEnum.view.wait_instock_product_view","enum.MultiDimensionViewEnum.viewName.wait_instock_product_view_name",XbbRefTypeEnum.WAIT_PURCHASE.getCode()),
    WAIT_PURCHAS_CONTRACT_VIEW(XbbRefTypeEnum.CONTRACT.getCode(), "enum.MultiDimensionViewEnum.view.wait_outstock_contract_view","enum.MultiDimensionViewEnum.viewName.wait_outstock_contract_view_name",XbbRefTypeEnum.WAIT_PURCHASE.getCode()),
    ;
    private int code;

    private String view;

    private String viewName;

    private int businessType;


    MultiDimensionViewEnum(int code, String view,String viewName, int businessType) {
        this.code = code;
        this.view = view;
        this.viewName = viewName;
        this.businessType = businessType;
    }

    public static List<MultiDimensionViewEnum> getByBusinessType(Integer businessType){
        List<MultiDimensionViewEnum> list = new ArrayList<>();
        for (MultiDimensionViewEnum value : values()) {
            if (Objects.equals(value.getBusinessType(),businessType)){
                list.add(value);
            }
        }
        return list;
    }

    public String getView() {
        return I18nMessageUtil.getMessage(view);
    }
    public String getViewName() {
        return I18nMessageUtil.getMessage(viewName);
    }
}
